package lib.Com;

import java.io.*;
import java.net.*;

public class BroadcastSelf extends Thread {
	/**
	 * Broadcast own ip and id for the KnownClients list of other users.
	 */
	protected DatagramSocket socket = null;
	protected BufferedReader in = null;

	public BroadcastSelf() {
		super("BroadcastSelf");
		try {
			socket = new DatagramSocket(5004);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void run() {
		try {
			byte[] msg = new byte[256];
			String tmp = Container.ID + "/" + Container.IPlocal + "/"
					+ Container.IPpublic + "/" + Container.Port1;
			msg = tmp.getBytes();
			InetAddress group = InetAddress.getByName("230.0.0.1");
			DatagramPacket packet = new DatagramPacket(msg, msg.length, group,
					5004);
			socket.send(packet);
		} catch (Exception e) {
			e.printStackTrace();
		}
		socket.close();
	}
}